/*
 * Tachometer.h
 *
 *  Created on: Jan 26, 2013
 *      Author: Drew Prevost
 */

#ifndef TACHOMETER_H_
#define TACHOMETER_H_

#include "Arduino.h"

class Tachometer
{
public:
  Tachometer();
  virtual ~Tachometer();

  static Tachometer & singleton();
  static void init(
                    int nIrqNum,
                    int nPin,
                    int nMode,
                    unsigned long nMillisDebounce = DFLT_TACH_DEBOUNCE );
  unsigned long getRpm();

protected:
  static void tachISR();

  const static unsigned int DFLT_TACH_DEBOUNCE = 100;

  static Tachometer instance;

  unsigned long nMillisLast;
  unsigned long nMillisCurrent;
  unsigned long nMillisDebounce;
  bool bInitialized;
};

#endif /* TACHOMETER_H_ */
